package cn.tedu.oop;

public class TestConstructor01 {
    public static void main(String[] args) {
        People1 spongBob=new People1("海绵宝宝",1,"男生");
        People1 Patrick=new People1("派大星",2,"男生");
        People1 p=new People1("zz",15);
        p.showAddressInMemory();
        spongBob.showAddressInMemory();
        Patrick.showAddressInMemory();
        System.out.println(spongBob.name);
        System.out.println(spongBob.age);
        System.out.println(spongBob.gender);
        System.out.println(Patrick.name);
        System.out.println(Patrick.age);
        System.out.println(Patrick.gender);
        System.out.println(p.name+p.age);
    }
}
class People1{
    String name;
    int age;
    String gender;
    public void showAddressInMemory(){
        System.out.println("打印this看到的虚拟地址："+this);
    }
    public People1() {
        System.out.println("我是无参构造");
    }

    public People1(String name, int age) {
        this.name = name;
        this.age = age;
        System.out.println("我是含参方法");
    }

    public People1(String name, int age, String gender) {
        this.name = name;
        this.age = age;
        this.gender = gender;
        System.out.println("我是全参方法");
    }
}